﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace NHDay_Linq.Domain
{
	public class Item
	{
		public int Id { get; set; }

		public string Name { get; set; }

		public bool Equals(Item other)
		{
			if (ReferenceEquals(null, other)) return false;
			if (ReferenceEquals(this, other)) return true;
			return other.Id == Id;
		}

		public override bool Equals(object obj)
		{
			if (ReferenceEquals(null, obj)) return false;
			if (ReferenceEquals(this, obj)) return true;
			if (obj.GetType() != typeof (Item)) return false;
			return Equals((Item) obj);
		}

		public override int GetHashCode()
		{
			return Id;
		}

		public static bool operator ==(Item left, Item right)
		{
			return Equals(left, right);
		}

		public static bool operator !=(Item left, Item right)
		{
			return !Equals(left, right);
		}
	}

	public class Items : ReadOnlyCollection<Item>
	{
		public Items() :
			base(new[]
		     	{
		     		new Item() { Id=1, Name="Knife"},
					new Item() { Id=1, Name="Fork"},
					new Item() { Id=1, Name="Spoon"},
				})
		{ }
	}
}
